Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Determining the Type of a QuickDraw 3D Object

Every class in the QuickDraw 3D class hierarchy has a unique type identifier associated with it. For example, the triangle class has the type identifier kQ3GeometryTypeTriangle . For objects you create, of course, you'll generally know the type of the object. In some instances, however, you might need to determine an object's type, so that you know what methods apply to the object. For example, when you read an object from a file, you don't usually know what kind of object you've read.

The QuickDraw 3D class hierarchy supports _GetType methods at all levels of the hierarchy. At the root level, the function Q3Object_GetType returns a constant of the form kQ3ObjectType SubClass , where SubClass is replaced by the appropriate subclass identifier.

For example, suppose you've read an object (which happens to be a triangle) from a file and you want to determine what kind of object it is. You can call the Q3Object_GetType function, which returns the value kQ3ObjectTypeShared . To determine what kind of shared object it is, you can call the Q3Shared_GetType function, which in this case returns the value kQ3SharedTypeShape . To determine what kind of shape object it is, you can call the Q3Shape_GetType function, which in this case returns the value kQ3ShapeTypeGeometry . Finally, you can determine what kind of geometric object it is by calling Q3Geometry_GetType ; in this case, Q3Geometry_GetType returns the value kQ3GeometryTypeTriangle .

Instead of descending the class hierarchy in this way, you can also determine the leaf type of an object by calling the Q3Object_GetLeafType function. (An object's leaf type is the identifier of a leaf class.) In this example, calling Q3Object_GetLeafType returns the constant kQ3GeometryTypeTriangle.

You can also use the Q3Object_IsType function to determine if an object is of a particular type.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |